package io.renren.modules.sys.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.renren.modules.common.BaseService;
import io.renren.modules.sys.dao.SysLogDao;
import io.renren.modules.sys.entity.SysLogEntity;
import io.renren.modules.sys.pojo.SysLogQuery;
import io.renren.modules.sys.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("sysLogService")
public class SysLogServiceImpl extends BaseService
		implements SysLogService {
	@Autowired
	private SysLogDao sysLogDao;
	
	@Override
	public SysLogEntity queryObject(Long id){
		return sysLogDao.queryObject(id);
	}
	
	@Override
	public List<SysLogEntity> queryList(SysLogQuery query){
		return sysLogDao.queryList(query);
	}

	@Override
	public PageInfo<SysLogEntity> queryPage(SysLogQuery query) {
		return PageHelper.startPage(query.getPage(),query.getLimit())
				.doSelectPageInfo(() -> sysLogDao.queryList(query));
	}

	@Override
	public long queryTotal(SysLogQuery query){
		return PageHelper.count(() -> sysLogDao.queryList(query));
	}
	
	@Override
	@Transactional
	public void save(SysLogEntity sysLog){
		sysLogDao.save(sysLog);
	}
	
	@Override
	@Transactional
	public void delete(Long id){
		sysLogDao.delete(id);
	}
	
	@Override
	@Transactional
	public void deleteBatch(Long[] ids){
		sysLogDao.deleteBatch(ids);
	}
	
}
